<div class="tableform">
    <form action="" method="post" id="barcode_manage">
    <{input type="hidden" name="bm_id" value=$barcode_info.bm_id }>
        <div class="division">
                <table width="100%" cellspacing="0" cellpadding="0">
                    <tbody>
                        <tr>
                            <td width="120" align="right">关联基础物料名称：</td>
                            <td><{$barcode_info.material_name }></td>
                        </tr>
                        <tr>
                            <td width="100" align="right">物料编码：</td>
                            <td><{$barcode_info.material_bn }></td>
                        </tr>
                        <tr>
                            <th width="80">条码：</th>
                            <td >
                                <{if $readonly.code == true}>
                                    <{$barcode_info.code}>
                                <{else}>
                                    <{input type="text&&required" name="code" value=$barcode_info.code }>
                                <{/if}>
                            </td>
                        </tr>
                    </tbody>
                </table>
        </div>

        <table width="100%" cellspacing="0" cellpadding="0">
        <tbody>
            <tr>
                <td colspan="2" align="center">
                    <{if $readonly.code == true}>
                    <{else}>
                        <{button class="btn-primary" label="确定" type="button" id="msaveBtn"}>
                    <{/if}>
                    <{button class="btn-primary" label="取消" type="button" id="mcancelBtn"}>
                </td>
            </tr>
        </tbody>
        </table>
    </form>
</div>
<script> 
    (function() {
        var form = $('barcode_manage');
        //关闭按钮
        $('mcancelBtn').addEvent('click', function(){
            $('mcancelBtn').getParent('.dialog').retrieve('instance').close();
        });

        //保存按钮
        $('msaveBtn').addEvent('click', function(){
            new Request ({
                url:'index.php?app=material&ctl=admin_barcode&act=toEdit',
                method:'post',
                data:form.toQueryString(),
                onRequest: function () {
                    $('msaveBtn').set('disabled', 'true');
                    $('mcancelBtn').set('disabled', 'true');
                },
                onSuccess: function(result) {
                    if (result =='SUCC') {
                        finderGroup["<{$env.get.finder_id}>"].refresh.delay(400,finderGroup["<{$env.get.finder_id}>"]);
                        $('msaveBtn').getParent('.dialog').retrieve('instance').close();
                    } else {
                        $('msaveBtn').set('disabled', '');
                        $('mcancelBtn').set('disabled', '');
                        //提示信息
                        alert(result);
                    }
                }
            }).send();
        });
    })();
</script>